<?php

require_once 'AipSpeech.php';

// 你的 APPID AK SK
const APP_ID = '11305053';
const API_KEY = 'bAvuWoH0k7Nil19bsi6nbeo1';
const SECRET_KEY = 'ysRBA4Yk7sBqdacQz7gkpquYd6bCnBQ0';

$client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY);

$result = $client->synthesis('宋欣女士，您老公喊你回家吃饭!', 'zh', 1, array(
    'vol' => 15,
));

// 识别正确返回语音二进制 错误则返回json 参照下面错误码
if(!is_array($result)){
    file_put_contents('audio.mp3', $result);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>音乐</title>
</head>
<body>
<audio controls autoplay="autoplay">
<source src="audio.mp3" />//音乐路径
</audio>
</body>
</html>

